//
//  AppUtils.m
//  Free Music
//
//  Created by GPF on 2017/3/6.
//  Copyright © 2017年 韩一博. All rights reserved.
//

#import "AppUtils.h"

@implementation AppUtils

+ (NSString *)getOSVersion{
    return [NSString stringWithFormat:@"%@ %@",[[UIDevice currentDevice] systemName],[[UIDevice currentDevice] systemVersion]];
}
//获取版本号
+(NSString*) getLocalAppVersion
{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
}
+ (NSString *)getLocalAppBuildVersion{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
}
//获取BundleID
+(NSString*) getBundleID{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
}

//获取app的名字
+(NSString*) getAppName
{
    NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
    NSMutableString *mutableAppName = [NSMutableString stringWithString:appName];
    return mutableAppName;
}

#pragma mark - 获取系统当前 地区 语言
//+ (NSString *)getSystemLanguage{
//    NSArray *languages = [NSLocale preferredLanguages];
//    if (languages.count <= 0){
//        return kLanguage_en;
//    }
//    NSString *currentLanguage = [NSString stringWithFormat:@"%@",[languages objectAtIndex:0]];
//    if ([currentLanguage isEqualToString:[NSString stringWithFormat:@"zh-HK"]] ||
//        [currentLanguage isEqualToString:[NSString stringWithFormat:@"zh-Hant"]]){
//        // zh-HK   繁体中文香港
//        currentLanguage = kLanguage_zh_Hant;
//    }
//    // zh-Hans 中简
//    // en      英语
//    // zh-Hant 繁体中文
//    // ja-US   日语
//    return currentLanguage;
//}
+ (NSDate *)getBeijingTimeDate
{
    NSDate *date = [NSDate date];
    NSTimeZone *zone = [NSTimeZone timeZoneWithName:@"Asia/Harbin"];
    NSInteger interval = [zone secondsFromGMTForDate: date];
    NSDate *localeDate = [date  dateByAddingTimeInterval: interval];
    return localeDate;
}
//得到本地时间
+ (NSString *)getBeijingTimeString
{
    NSDate *date = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    return  [formatter stringFromDate:date];
}

+ (NSString *)getSystemArea{
    NSLocale *currentLocale = [NSLocale currentLocale];
    NSString *area = [currentLocale objectForKey:NSLocaleCountryCode];
//    if ([area isEqualToString:@"CN"] || [area isEqualToString:@"HK"] || [area isEqualToString:@"MO"]) {
//        area = @"IS_CHINA";
//    }
//    if (![SettingObject objectIsValid:area]){
//        area = @"";
//    }
    return area;
    
}
@end
